class CacheEvaluationContext extends StandardEvaluationContext
Also define a set of "unavailable variables" (i.e. variables that should lead to an exception right the way when they are accessed). This can be useful to verify a condition does not match even when not all potential variables are present.
To limit the creation of objects, an ugly constructor is used (rather then a dedicated 'closure'-like class for deferred execution).
Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
args |
private java.lang.reflect.Method |
method |
private java.util.Map<MethodCacheKey,java.lang.reflect.Method> |
methodCache |
private ParameterNameDiscoverer |
paramDiscoverer |
private boolean |
paramLoaded |
private java.lang.Class<?> |
targetClass |
private java.util.List<java.lang.String> |
unavailableVariables |
Constructor and Description |
---|
CacheEvaluationContext(java.lang.Object rootObject,
ParameterNameDiscoverer paramDiscoverer,
java.lang.reflect.Method method,
java.lang.Object[] args,
java.lang.Class<?> targetClass,
java.util.Map<MethodCacheKey,java.lang.reflect.Method> methodCache) |
Modifier and Type | Method and Description |
---|---|
void |
addUnavailableVariable(java.lang.String name)
Add the specified variable name as unavailable for that context.
|
private void |
loadArgsAsVariables() |
java.lang.Object |
lookupVariable(java.lang.String name)
Load the param information only when needed.
|
addConstructorResolver, addMethodResolver, addPropertyAccessor, getBeanResolver, getConstructorResolvers, getMethodResolvers, getOperatorOverloader, getPropertyAccessors, getRootObject, getTypeComparator, getTypeConverter, getTypeLocator, registerFunction, registerMethodFilter, removeConstructorResolver, removeMethodResolver, removePropertyAccessor, setBeanResolver, setConstructorResolvers, setMethodResolvers, setOperatorOverloader, setPropertyAccessors, setRootObject, setRootObject, setTypeComparator, setTypeConverter, setTypeLocator, setVariable, setVariables
private final ParameterNameDiscoverer paramDiscoverer
private final java.lang.reflect.Method method
private final java.lang.Object[] args
private final java.lang.Class<?> targetClass
private final java.util.Map<MethodCacheKey,java.lang.reflect.Method> methodCache
private final java.util.List<java.lang.String> unavailableVariables
private boolean paramLoaded
CacheEvaluationContext(java.lang.Object rootObject, ParameterNameDiscoverer paramDiscoverer, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Class<?> targetClass, java.util.Map<MethodCacheKey,java.lang.reflect.Method> methodCache)
public void addUnavailableVariable(java.lang.String name)
This permits the validation of expressions that could potentially a variable even when such variable isn't available yet. Any expression trying to use that variable should therefore fail to evaluate.
public java.lang.Object lookupVariable(java.lang.String name)
lookupVariable
in interface EvaluationContext
lookupVariable
in class StandardEvaluationContext
name
- variable to lookupprivate void loadArgsAsVariables()